/****************************************************************************
**                                                                         **
**                       PSSDK HNTcpSession module                         **
**            Copyright (c) 1997 - 2006 microOLAP Technologies LTD,        **
**                       Khalturin A.P., Naumov D.A.                       **
**                               Header File                               **
**                                                                         **
****************************************************************************/

//---------------------------------------------------------------------------
#ifndef __HN_PSSDK_TCPSESSION_H__
#define __HN_PSSDK_TCPSESSION_H__ 
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// Class CHNTcpSession
//---------------------------------------------------------------------------
class CHNTcpSession
{
private:
    HANDLE hTcpSes;

public:
    //###########################################################################
    //    Create and Destroy
    //###########################################################################

    //---------------------------------------------------------------------------
    // Constructor
    CHNTcpSession() { hTcpSes = NULL; }

    //---------------------------------------------------------------------------
    // Destructor
    ~CHNTcpSession() {}

public:
    //###########################################################################
    //    Additionals methods
    //###########################################################################
    BOOL     IsValid() { return (hTcpSes != NULL); }
    HANDLE   Set_Handle(HANDLE hTcpSes) { return this->hTcpSes = hTcpSes; }
    HANDLE   Get_Handle() { return hTcpSes; }
    operator HANDLE() { return hTcpSes; }
    HANDLE   operator =(HANDLE hTcpSes) { return this->hTcpSes = hTcpSes; }


public:
    //###########################################################################
    //    Methods of redirect
    //###########################################################################

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetState - Returns the TCP session state.
    DWORD Get_State() 
    { return TcpSesGetState(hTcpSes); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetCloseReason - Returns the reason why the TCP session has been closed.
    DWORD Get_CloseReason() 
    { return TcpSesGetCloseReason(hTcpSes); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetCreateTime - Returns the TCP session creation time.
    DWORD Get_CreateTime() 
    { return TcpSesGetCreateTime(hTcpSes); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetLastPacketTime - Returns the time of receiving of the last packet participated in TCP connection.
    DWORD Get_LastPacketTime() 
    { return TcpSesGetLastPacketTime(hTcpSes); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetClientIP - Returns IP address of the client participating in the connection.
    DWORD Get_ClientIP() 
    { return TcpSesGetClientIP(hTcpSes); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetClientPort - Returns port number of the client participating in the connection.
    USHORT Get_ClientPort() 
    { return TcpSesGetClientPort(hTcpSes); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetServerIP - Returns IP address of the server participating in the connection.
    DWORD Get_ServerIP() 
    { return TcpSesGetServerIP(hTcpSes); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetServerPort - Returns port number of the server participating in the connection.
    USHORT Get_ServerPort() 
    { return TcpSesGetServerPort(hTcpSes); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetClientPacketsCount - Returns the number of packets sent by client.
#ifdef _WIN64
    ULONGLONG Get_ClientPacketsCount() 
    { return TcpSesGetClientPacketsCount(hTcpSes); }
#else
    DWORD Get_ClientPacketsCount(DWORD *pHiValue) 
    { return TcpSesGetClientPacketsCount(hTcpSes,pHiValue); }
#endif //_WIN64

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetClientDataSize - Returns the size of data sent by client.
#ifdef _WIN64
    ULONGLONG Get_ClientDataSize() 
    { return TcpSesGetClientDataSize(hTcpSes); }
#else
    DWORD Get_ClientDataSize(DWORD *pHiValue) 
    { return TcpSesGetClientDataSize(hTcpSes,pHiValue); }
#endif //_WIN64

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetServerPacketsCount - Returns the number of packets sent by server.
#ifdef _WIN64
    ULONGLONG Get_ServerPacketsCount() 
    { return TcpSesGetServerPacketsCount(hTcpSes); }
#else
    DWORD Get_ServerPacketsCount(DWORD *pHiValue) 
    { return TcpSesGetServerPacketsCount(hTcpSes,pHiValue); }
#endif //_WIN64

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetServerDataSize - Returns the size of data sent by server.
#ifdef _WIN64
    ULONGLONG Get_ServerDataSize() 
    { return TcpSesGetServerDataSize(hTcpSes); }
#else
    DWORD Get_ServerDataSize(DWORD *pHiValue) 
    { return TcpSesGetServerDataSize(hTcpSes,pHiValue); }
#endif //_WIN64

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesGetUserData - Returns user-defined value associated with TCP session.
    DWORD_PTR Get_UserData() 
    { return TcpSesGetUserData(hTcpSes); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpSesSetUserData - Sets user-defined value associated with TCP session.
    DWORD_PTR Set_UserData(DWORD_PTR UserData) 
    { return TcpSesSetUserData(hTcpSes,UserData); }

    //---------------------------------------------------------------------------
    // v2.4 - TcpSesSwapClientServer - Swap client/server properties 
    VOID SwapClientServer()
    { TcpSesSwapClientServer(hTcpSes); }
};


//---------------------------------------------------------------------------
#endif // __HN_PSSDK_TCPSESSION_H__
//---------------------------------------------------------------------------
